<template>
  <div>
    <el-card>
      <el-button type="primary" @click="handleAdd">离职申请</el-button>
      <el-table
        :data="tableData"
        style="width: 100%"
         align="center"
        >
        <el-table-column
          prop="name"
          label="姓名"
           align="center"
        >
        </el-table-column>
         <el-table-column
          prop="account"
          label="账号"
           align="center"
        >
        </el-table-column>
        <el-table-column
          prop="portrait"
          label="门店"
           align="center">
        </el-table-column>
       
        <el-table-column
          prop="role"
          label="部门"
           align="center"
        >
        </el-table-column>
          <el-table-column
        prop="status"
        label="状态"
        align="center"
      >
       <template slot-scope="scope">
          <span v-if="scope.row.status == 0">在职</span>
          <span v-else>离职</span>
        </template>
      </el-table-column>
      
         <el-table-column
          prop="remark"
          label="申请离职时间"
           align="center"
        >
        </el-table-column>
          <el-table-column
          prop="remark"
          label="办理离职时间"
           align="center"
        >
        </el-table-column>
         <el-table-column label="操作"  align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            @click="Edit(scope.row.id)">编辑
          </el-button>
          <el-button
            size="mini"
            type="danger"
            @click="Delete(scope.row.id)">删除
          </el-button>
        </template>
      </el-table-column>
      </el-table>
      <!--分页组件-->
    <el-pagination
      @current-change="handleCurrentChange"
      layout="total, prev, pager, next"
      :total="total"
    ></el-pagination>
    </el-card>
    <create ref="create" @Ok="handleInit"></create>
  </div>
</template>

<script>
  import {getList} from "@/api/sales";
    import {remove} from "@/api/sales";
  import Create from "./components/create";

  export default {
    name: "index",
    components: {
      Create
    },
    data() {
      return {
        value: '',
        tableData: [],
        page: 1,
        size: 10,
        total: 1,
        id:'',
        
      }
    },
    mounted() {
      this.handleInit()
    },
    methods: {
      //销售列表
      handleInit() {
        getList(this.page, this.size).then(res => {
          this.tableData = res.result.records
          this.total = Number(res.result.total)
        })
      },
      //添加销售
      handleAdd() {
        this.$refs['create'].show()
      },
      handleNext(e) {
        this.page = e
        this.handleInit()
      },
      //编辑
      Edit(){

      },
      //删除
      Delete(id){
        this.id=id
        let form={
          id:this.id
        }
  remove(form).then(res => {
        if (res.status == 200) {
          this.$message.success('删除成功');
          this.handleInit()
          
        }
        })
      },
      //编辑状态
      swit(){

      },
      //分页
      handleCurrentChange (val) {
      this.page = val
      this.handleInit()
    }
    }
  }
</script>

<style scoped>

</style>
